﻿// -----------------------------------------------------------------------
// <copyright company="Christoph van der Fecht - VDsoft">
// Copyright (C) Christoph van der Fecht - VDsoft - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited,
// unless it is communicated and authorized by the copyright owner.
// </copyright>
// -----------------------------------------------------------------------

using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SeriesManager.ViewModel
{
	/// <summary>
	/// View model for the about dialog.
	/// </summary>
	public class AboutDialogViewModel : ViewModelBase
	{
		/// <summary>
		/// The Title.
		/// </summary>
		private string title = null;

		/// <summary>
		/// The Version.
		/// </summary>
		private string version = null;

		/// <summary>
		/// The CopyRight.
		/// </summary>
		private string copyRight = null;

		/// <summary>
		/// The Description.
		/// </summary>
		private string description = null;

		/// <summary>
		/// Initializes a new instance of the <see cref="AboutDialogViewModel"/> class.
		/// </summary>
		public AboutDialogViewModel()
		{
			if (this.IsInDesignMode)
			{
				this.Title = "The name of the application which could be long.";
				this.Version = "20.10.12.320";
				this.CopyRight = "Copyright Christoph van der Fecht - VDsoft 2013";
				this.Description = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam";
			}
			else
			{
				Assembly ass = Assembly.GetExecutingAssembly();
				AssemblyTitleAttribute title = (AssemblyTitleAttribute)ass.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0];
				AssemblyProductAttribute product = (AssemblyProductAttribute)ass.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];
				AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)ass.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0];
				AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)ass.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0];
				AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)ass.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0];

				this.Title = product.Product;
				this.Version = ass.GetName().Version.ToString();
				this.CopyRight = copyright.Copyright;
				this.Description = description.Description;
			}
		}

		/// <summary>
		/// Gets or sets the Title.
		/// </summary>
		public string Title
		{
			get
			{
				return this.title;
			}

			set
			{
				if (value == this.title)
				{
					return;
				}

				this.title = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Version.
		/// </summary>
		public string Version
		{
			get
			{
				return this.version;
			}

			set
			{
				if (value == this.version)
				{
					return;
				}

				this.version = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the CopyRight.
		/// </summary>
		public string CopyRight
		{
			get
			{
				return this.copyRight;
			}

			set
			{
				if (value == this.copyRight)
				{
					return;
				}

				this.copyRight = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Description.
		/// </summary>
		public string Description
		{
			get
			{
				return this.description;
			}

			set
			{
				if (value == this.description)
				{
					return;
				}

				this.description = value;
				this.RaisePropertyChanged();
			}
		}
	}
}
